package com.action.service.pressenter;

import com.action.childbase.ChildBasePressent;
import com.action.service.ChildRestServer;
import com.base.app_core.base.BaseView;
import com.base.app_core.model.Paginated;
import com.base.app_core.model.rqview.WxLoginView;
import com.base.app_core.service.Retrofit.RestServer;
import com.base.app_core.service.rx.Callback;
import com.base.app_core.service.user.model.User;
import com.base.app_core.util.BeanPropertiesUtil;
import com.base.app_core.util.log.F;

import javax.inject.Inject;

/**
 * Created by woody on 2018/4/2.
 */

public class EntryPressenter extends ChildBasePressent<BaseView> {


    @Inject
    User user;

    @Inject
    public EntryPressenter(ChildRestServer mRestfull, RestServer server) {
        super(mRestfull, server);
    }

    //微信登录
    public void wxLogin(String code) {
        invoke(mRestfull.wxLogin(new WxLoginView(code)), new Callback<User>() {
            @Override
            public void onResponse(User data, Paginated paginated,Object extraData) {
                //登录成功
                try {
                    BeanPropertiesUtil.copyProperties(data, user);
                    F.j(user.getCreatedAt());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                super.onResponse(data, paginated,extraData);
            }
        });
    }
}
